package com.kaifamiao.operators;

// 扩展后的赋值运算符
// += 、-= 、*= 、/= 、%=
// |= 、&= 、^= 、>>= 、<<= 、>>>=
public class Tiger {
    public static void main(String[] args) {

        int a = 100;
        a += 50; // 效果上等同于 a = a + 50
        System.out.println( a );

        int b = 10;
        b /= 3; // 效果上等同于 b = b / 3
        System.out.println( b );

        int c = 10;
        c %= 3; // 效果上等同于 c = c % 3
        System.out.println( c );

        System.out.println( "- ".repeat( 10 ) );

        byte d = 15;
        d += 5; // 务必注意与 d = d + 5 的区别
        System.out.println( d );

        byte e = 15;
        int f = e + 5;

        System.out.println( "- ".repeat( 10 ) );

        int x = 0b0000_0000_0000_0000_0000_0000_0000_0111;
        int y = 0b0000_0000_0000_0000_0000_0000_0000_0101;
        x ^= y; // 效果上等同于 x = x ^ y
        System.out.println( x );

        System.out.println( "- ".repeat( 10 ) );

        int p = 0b0000_0000_0000_0000_0000_0000_0000_0101;
        System.out.println( p );
        p >>= 1; // 效果上等同于 p = p >> 1
        System.out.println( p );

    }
}
